//
//  MPFrostedViewController.m
//  MarkPlatform
//
//  Created by xiao6 on 2017/12/17.
//  Copyright © 2017年 AT. All rights reserved.
//

#import "MPFrostedViewController.h"
#import "MPMineController.h"
#import "MPHomeController.h"
#import "MPCompanyTaskController.h"
#import "MPLoginController.h"

@interface MPFrostedViewController ()

@end

@implementation MPFrostedViewController
- (instancetype)init {
    if (self = [super init]) {
        self.contentViewController = [[BaseNavigationController alloc] initWithRootViewController:[[MPHomeController alloc] init]];
        self.menuViewController = [[MPMineController alloc] init];
        self.limitMenuViewSize = YES;
        self.menuViewSize = CGSizeMake(SCALEW(240), SCREEN_HEIGHT);
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupData];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupData) name:ATEnterpriseUpdateNotification object:nil];
    
    if (![ATLocal isLogin]) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.contentViewController presentViewController:[[BaseNavigationController alloc] initWithRootViewController:[[MPLoginController alloc] init]] animated:NO completion:nil];
        });
    }
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)setupData {
    if ([ATLocal isEnterprise]) {
        self.contentViewController = [[BaseNavigationController alloc] initWithRootViewController:[[MPCompanyTaskController alloc] init]];
    }
    else {
        self.contentViewController = [[BaseNavigationController alloc] initWithRootViewController:[[MPHomeController alloc] init]];
    }
}
@end
